﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace _上传Excel导入数据库.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult UploadExcel()
        {
            ///workbooks
            HttpPostedFileBase file = Request.Files[0];
            string path = "";
            string strConn;
            strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + "; " + "Extended Properties=Excel 8.0;";
            OleDbDataAdapter oda = new OleDbDataAdapter("Select * from [Sheet1$]", strConn);
            DataSet ds = new DataSet();
            oda.Fill(ds,"ExcelTable");


            return View();
        }
    }
}